﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="YUIDataTableList.aspx.cs" Inherits=" ZX.Web.UI.Controls.YUIList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <!--CSS file (default YUI Sam Skin) -->
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/calendar/assets/skins/sam/calendar.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/paginator/assets/skins/sam/paginator.css" />

    <!--begin custom header content for this example-->
    <style type="text/css">
    .yui-skin-sam table {
	  width: 100%; 
    }
    
    #button-example-form fieldset, 
    #button-example-form fieldset div {
        border: 2px groove #ccc;
        margin: .5em;
        padding: .5em;
    }
    <% =DataTableCss %>
</style>
    <!--end custom header content for this example-->
    <!-- Dependencies -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <!-- OPTIONAL: JSON Utility (for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <!-- OPTIONAL: Calendar (enables calendar editors) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <!-- Source files -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>

    <script type="text/javascript" src="../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/Public.js" type="text/javascript"></script>
    <script src="../Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../Scripts/fullscreen.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
</head>
<body class="yui-skin-sam">

       <div style="display:none;background-color:#eee;" id="full">
       <div style="width:500px;height:450px; padding:50px; margin:50x;">
          <div style="border:1px solid #ddd; padding:15px;">
          <label>请输入密码：</label><br />
          <span><input  type="password" id="tPassword" style="width:200px"/></span>
          </div>
          <div style=" padding-left:160px;border:1px solid #ddd;">
            <button id="btnCheck" name="btnCheck">确定</button>
          </div>
       </div>
    </div>
    <!-- 工具栏 -->
    <div id="listpage">
        <div id="toolbar" style="margin: 2px;">
        <% if (QuciklyQueryFields != string.Empty)
         {  %><div style=" float:right;"><input type="checkbox" id="checkAndOr" /><span style="margin-top:-5px;">并集</span> <input id="QueryContext" type="text"/><button type="button" id="btnQuickQuery" name="btnQuickQuery" style="height:20px;" onclick="javascript:fnQuciklyQuery();">搜</button></div><%} %>

            <% =BtnItems %>                <%if (GetStringFromQueryString("isShonwBtn","Y") != "N")
                   { %>
                   <button type="button" id="btnFull" name="btnFull" title="全屏"></button>
                <button type="button" id="btnModuleHelp" name="btnModuleHelp" title="帮助">
                帮助</button>
                <button type="button" id="btnReload" name="btnReload" title="刷新">
                </button> <%--<button type="button" id="btnClose" name="btnClose">
                关闭当前页</button> --%>
                <%} %>
        </div>
        <div id="data">
            <div id="json">
            </div>
        </div>
        <div id="bottom">
        <div id="pagetotal" style="float:left;height:25px; padding:8px;margin-top:3px;width:100px;"></div><div id="page" style="float:left"></div> 
        </div>
    </div> 
    <!-- 对话框 -->
    <div id="dialogArea" style="display:none">
    <div id="dialog1" class="yui-pe-content"  >
        <div class="hd">
           <% =PageTitle %>数据编辑</div>
        <div class="bd">
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
        
    <div id="dialog2" class="yui-pe-content" >
        <div class="hd">
            选择基本信息:</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog3" class="yui-pe-content"  >
        <div class="hd">
            提示</div>
        <div class="bd">
            你正在删除当前选择的数据，继续请按确定？
        </div>
    </div>
 
    <div id="dialog4" class="yui-pe-content">
        <div class="hd">
            查询</div>
        <div class="bd">
           <iframe id="QueryWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    
    <div id="dialog5" class="yui-pe-content" >
        <div class="hd">
           <% =PageTitle %> 数据详情</div>
        <div class="bd">
            <iframe id="EditUIWindow3" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog6" class="yui-pe-content"  >
        <div class="hd">
           <% =PageTitle %>数据编辑</div>
        <div class="bd">
            <iframe id="EditUIWindow6" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    </div>
    <form id="form2" action="AjaxData/DataSave.aspx">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    <textarea style="display: none" id="jsonDetails" rows="2" cols="2" name="Details"></textarea>
    </form>
</body>
<!-- 通用方法 -->
<script src="../Scripts/common.js" type="text/javascript"></script>
<!-- 定义数据格式化方法 -->
<script src="../Scripts/yui.list.dataformat.js" type="text/javascript"></script>
<!--  用于加载自定义脚本 -->
<script src="../Scripts/appjs/model.<% =EntityName %>.js" type="text/javascript" language="javascript"></script> 
<script type="text/javascript">

var formatMethod = function (elCell, oRecord, oColumn, sData) {
    elCell.innerHTML = (sData==0)? "培训资料":"公告";
};


function IsView()
{
    return (''+this.location).indexOf("V_UserRole")>-1;
}   
//密码验证
function fnCheck(){
    $("#btnCheck").attr("disabled",true);
    var pwd = $("#tPassword").val();
    YAHOO.util.Connect.asyncRequest('POST', "../EHR/hrSalaryAjax.aspx?flag=checkpwd&userPwd=" + pwd+"&r="+Math.random(), {
        success: function (res) {
            try {
                var str = res.responseText;
                if (str == "0") {
                    $("#tPassword").val("");
                    _unfullScreen();
                }
                else {
                    alert("密码错误!");
                }
                $("#btnCheck").attr("disabled",false);
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
}
 var const_entityID = "<% =EntityId %>",    //实体ID名称
        const_entityName = "<% =EntityName %>",//实体名称
        const_EditEntity = "<% =EditEntity %>",//编辑实体名
        const_functionId   ="<% =FunctionID %>",//自定义条件
        const_Order ="<% =Order %>",           //排序  
        const_UserId = "<% = UserId %>",       //

        const_QueryField="<% =QuciklyQueryFields %>",
        const_DataFields = [<% =DataFields %>],
        const_DataColums = [<% =DataColums %>],
        const_EditWindowWidth = "<% =EditWindowWidth %>px",
		const_EditWindowHeight = "<% =EditWindowHeight %>px",
        const_CustomCondition = encodeURI("<% =DefineCondition %>"),//查询方案条件
        const_Condition =  encodeURI("<% =Condition %>"),
        const_PageTitle=encodeURI("<% =PageTitle %>"),
        selectControl=null,
        requireUrl="",
        //initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ const_CustomCondition,
        initialRequestUrl = "pageindex="+(IsView()?0:1)+"&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ const_CustomCondition+"&condition="+const_Condition,
        SaveUrl,dl,//要删除的数据列  
        const_height,const_width;
    (function () {
        var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
        const_height =  Dom.getViewportHeight();
        const_width  = Dom.getViewportWidth();
        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                height: const_height,
                width: const_width,
                units:   IsView()? [
                //{ position: 'top',height: 35, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
                //{ position: 'left', header: '功能模块', width: 250, body: 'left', gutter: '1 5 1 1', collapse: true, scroll: true, zIndex: 1, resize: true },
                {position: 'center', body: 'data', gutter: '1 1', scroll: false },
                { position: 'bottom', height: 35, body: 'bottom', gutter: '1 1'}
            ]: [
                { position: 'top',height: 35, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
                //{ position: 'left', header: '功能模块', width: 250, body: 'left', gutter: '1 5 1 1', collapse: true, scroll: true, zIndex: 1, resize: true },
                {position: 'center', body: 'data', gutter: '1 1', scroll: false },
                { position: 'bottom', height: 35, body: 'bottom', gutter: '1 1'}
            ]
            });
            layout.render();
        });
    })();

    
    YAHOO.example.init = function () {
        // "click" event handler for each Button instance
        function onButtonClick(p_oEvent) {
                 YAHOO.log("You clicked button: " + this.get("id"), "info", "example1");
                 switch(this.get("id"))
                 { 
                     <% =InitBtnEvents %>
                    case "btnFull": 
                         fnFull();
                         break;
                    case "btnModuleHelp":
                         fnModuleHelp();
                         break;
                    case "btnClose":
                         window.parent.$("#tabs").tabs('close','<% =PageTitle %>');
                         break;
                    case "btnReload":
                         fnReload();
                         break;
                    case "btnCheck":
                         fnCheck();
                         break;
                    default:
                         break;
                 }                        
        }


        YAHOO.util.Event.onContentReady("toolbar", function () {
        <% =BtnEvents  %>
                         <%if (GetStringFromQueryString("isShonwBtn","Y") != "N")
                   { %>
        var btnFull = new YAHOO.widget.Button("btnFull");
        btnFull.on("click", onButtonClick);
        var btnModuleHelp = new YAHOO.widget.Button("btnModuleHelp");
        btnModuleHelp.on("click", onButtonClick);
        var btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick);

        var btnReload = new YAHOO.widget.Button("btnReload");
        btnReload.on("click", onButtonClick);

        var btnCheck=new YAHOO.widget.Button("btnCheck");
        btnCheck.on("click", onButtonClick);

                <%} %>
        });
    }();
    var _need = 0;
    $(document).ready(function(){
        //
        if((const_entityName =="V_salBaseSalary" || const_entityName =="V_salSalaryInterception" || 
        const_entityName =="V_salBasicSubsidy" || const_entityName =="V_salLargeClassBonus" || 
        const_entityName =="V_salPerformanceBonus" || const_entityName =="V_salSalaryReissue" ||
        const_entityName =="V_salOvertimeFee" || (const_entityName =="V_salEmployeeSalaryResult" && location.href.indexOf("eYUITreeList.aspx")>0)) && _need == 0)
        {
            _fullScreen();
            _need = 1;
        }
    })

</script> 

<!-- YUI  通用功能  -->
<script src="../Scripts/yui.list.data.common.js" type="text/javascript"></script>  
<!--  用于加载按扭方法 -->
<script src="../Scripts/yui.list.button.event.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    window.document.getElementById("dialogArea").style.display = "";
</script>
<script language="javascript" type="text/javascript">
    //保存
    var Save = function (action) {
        var list = mDataTable.getRecordSet()._records;
        var elist = [];
        for (var i = 0; i < list.length; i++) {
            elist.push(list[i]._oData);
        }

        url = "AjaxData/DataSave.aspx";
        var jsonStr = YAHOO.lang.JSON.stringify(elist);
        var TextCtrl = document.getElementById("jsonDataContent");
        TextCtrl.value = jsonStr;
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        var SaveUrl = url + "?r=" + Math.random() + "&flag=1&action="+action+"&functionid=" + const_functionId + "&entity=" + const_entityName; //+"&json=" + encodeURI(jsonStr.replace(/&/g,"[A]").replace(/'/g,"''"));
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        alert("数据保存成功");
                        //parent.closeWin();
                    }
                    else {
                        alert(str + "\n" + "数据保存失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }

    YAHOO.util.Event.addListener(document, 'keydown', function (ev) {
        if (ev.ctrlKey && ev.keyCode == "72") {
            fnModuleHelp();
            //alert("帮助");
        }
        if (ev.ctrlKey && ev.keyCode == "83") {

            fnListSetting();
            //alert("设置");
        }

        if (ev.ctrlKey && ev.keyCode == "85") {
            _fullScreen();
        }
    });
</script>
</html>
